<?php
require_once 'include/prepend.php';
if(isset($_POST['save'])){
	$entreprise	 = (int)$_POST['entreprise'];
	$type_mea	 = (int)$_POST['type_mea'];
	$date_debut  = $_POST['date_debut'];
	$date_fin 	 = $_POST['date_fin'];
	$active		 = $_POST['active'];
	$mea 		 = new BDmise_en_avant();
	$mea->setId_entreprise($entreprise);
	$mea->setId_type_mea($type_mea);
	$mea->setDate_debut($date_debut);
	$mea->setDate_fin($date_fin);
	$mea->setActive($active);
	if($mea->save())
	Application::forceRedirect("gestion_mea.php");
		else 
	var_dump($mea->funcErrors());

}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<script type="text/javascript">
	$(function() {
		$("#date_debut").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: "yy-mm-dd",
			altField: '#alternate1', altFormat: 'DD, d MM, yy',
			
		});
		$("#date_fin").datepicker({
			changeMonth: true,
			changeYear: true,
			dateFormat: "yy-mm-dd",
			altField: '#alternate2', altFormat: 'DD, d MM, yy'
		});
	});
	</script>
</head>
<body>
<h1><img src="images/gestion_mea.png" align="absmiddle" />Ajouter une nouvelle Mise en avants</h1>
<link href="./css/gestion_mea_add.css" rel="stylesheet" type="text/css" /> 
<form action="gestion_mea_add.php" class="cmxform" method="post"> 
	<p>Champs obligatoires <em>*</em></p> 
	<fieldset> 
		<legend>Choix de l'entreprise en question</legend> 
		<ol> 
		<li>
		<?php echo select_one('entreprise', BDentreprise::get(), "Entreprise <em>*</em>", '');?>
		</li> 
		</ol> 
	</fieldset> 
	<fieldset> 
		<legend>Programmation de la mise en avant</legend> 
		<ol> 
			<li>
			<?php echo select_one('type_mea', BDtype_mise_en_avant::get(), "Type de MEA <em>*</em>", '');?>
			</li> 
			<li><label for="date_debut">Date d&eacute;but <em>*</em></label>
			<input type="text" id="date_debut" name="date_debut" />
			&nbsp;<input type="text" id="alternate1" size="30"/></li> 
			<li><label for="date_fin">Date fin <em>*</em></label>
			 <input type="text" id="date_fin" name="date_fin" />
			&nbsp;<input type="text" id="alternate2" size="30"/></li> 
			<?php echo radios_set('active', 'Active <em>*</em>', array(array('id'=>0, 'text'=>'non'), array('id'=>1, 'text'=>'oui')), 0);?>
		</ol> 
	</fieldset> 
	<p><input type="submit" name="save" value="Enregistrer la MEA" />
<input type="reset" value="Annuler la MEA" /></p> 
</form> 
</body>
</html>